package com.cloud.leetcode;


/**
 * @program: basic
 * @description: 两数之和
 * @author: Cloud
 * @create: 2022/2/28 10:47:47
 */
public class TwoSum {

    public static int[] twoSum(int[] nums, int target) {
        int a[] = {};
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length; j++) {
                if (target == nums[i]+nums[j]) {
                    System.out.println(""+nums[i]+" "+nums[j]);
                    a = new int[]{i, j};
                    break;
                }
            }
        }
        return a;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{2,7,11,15};
        int target = 9;
        int[] ints = twoSum(nums, target);
        for (int anInt : ints) {
            System.out.println("anInt = " + anInt);
        }
    }
}
